home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module 7- switching compositors / source / mainframe.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  4.2 KB  |  112 lines

  1. import java.awt.*;
  2. import java.awt.event.*;
  3.  
  4. import quicktime.QTException;
  5. import quicktime.QTSession;
  6. import quicktime.app.display.QTCanvas;
  7.  
  8. /**
  9.  * QTZoo Module 6 - Advanced Compositing and Event Handling
  10.  * This application requires QuickTime for Java
  11.  *
  12.  * @author Levi Brown
  13.  * @author Michael Hopkins
  14.  * @author Apple Computer, Inc.
  15.  * @version 1.0 4/10/2000
  16.  *
  17.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  18.  *    
  19.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  20.  *                ("Apple") in consideration of your agreement to the following terms, and your
  21.  *                use, installation, modification or redistribution of this Apple software
  22.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  23.  *                please do not use, install, modify or redistribute this Apple software.
  24.  *
  25.  *                In consideration of your agreement to abide by the following terms, and subject
  26.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  27.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  28.  *                reproduce, modify and redistribute the Apple Software, with or without
  29.  *                modifications, in source and/or binary forms; provided that if you redistribute
  30.  *                the Apple Software in its entirety and without modifications, you must retain
  31.  *                this notice and the following text and disclaimers in all such redistributions of
  32.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  33.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  34.  *                Apple Software without specific prior written permission from Apple.  Except as
  35.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  36.  *                are granted by Apple herein, including but not limited to any patent rights that
  37.  *                may be infringed by your derivative works or by other works in which the Apple
  38.  *                Software may be incorporated.
  39.  *
  40.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  41.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  42.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  43.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  44.  *                COMBINATION WITH YOUR PRODUCTS.
  45.  *
  46.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  47.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  48.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  50.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  51.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  52.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  53.  * 
  54.  */
  55.  
  56.  
  57. public class MainFrame extends Frame
  58. {
  59.     public static final int WIDTH  = 640;
  60.     public static final int HEIGHT = 480;
  61.  
  62.     /**
  63.      * Creates the QTCanvas, loads media, and displays window contents
  64.      */
  65.     public MainFrame( String s )
  66.     {
  67.         super( s );
  68.         setResizable( false );
  69.         setBounds( 0, 0, WIDTH, HEIGHT );
  70.         
  71.         myQTCanvas = new QTCanvas( QTCanvas.kInitialSize, 0.5F, 0.5F ); // Create new QT Canvas
  72.         add( myQTCanvas );
  73.  
  74.         loadPanes( );                                                    // Load the zebra pane
  75.  
  76.         addWindowListener( new WindowAdapter()                             // Registers a listener for the window close box
  77.         {
  78.             public void windowClosing( WindowEvent we )
  79.             {
  80.                 QTSession.close();                                        // shut down QT and clean up
  81.                 dispose();                                                // destroy window
  82.             }
  83.             public void windowClosed( WindowEvent we )
  84.             {
  85.                 System.exit( 0 );                                        // exit to shell
  86.             }
  87.         });
  88.         
  89.         show();                                                            // Show the window and bring to front        
  90.         toFront();
  91.     }
  92.  
  93.     /**
  94.      * Loads the data displayed in each of the animal panes
  95.      */
  96.     public void loadPanes()
  97.     {
  98.         AnimalPane zebraPane = new AnimalPane( );
  99.         try
  100.         {
  101.             myQTCanvas.setClient( zebraPane.getCompositor(), true );    // Set the canvas to display the map pane
  102.             zebraPane.start();                                            // Start the compositor and register event handler for custom controller
  103.         }
  104.         catch (QTException exc)
  105.         {
  106.             exc.printStackTrace();
  107.         } 
  108.     }
  109.     
  110.     protected QTCanvas myQTCanvas;
  111. }
  112.